package com.njwb.day05;

public class Test04 {
    public static void main(String[] args) {
        /*System.out.println(D.i);
        D.fn1();*/
        new D();
        new D();
        new D();
        new D();
        new D();
    }
}

class D{
    //静态代码块：类加载到内存中时,当前类第一次加载时执行
    static {
        System.out.println("D.static initializer");
        //调用静态属性和方法
        System.out.println(D.i);
        D.fn1();
        //调用成员属性和方法
        D d=new D();
        System.out.println(d.j);
        d.fn2();
    }

    public D(){
        System.out.println("D.D()");
    }

    static int i=10;
    int j=20;

    public static void fn1(){
        System.out.println("D.static fn1");
    }
    public void fn2(){
        System.out.println("D.fn2");
    }

}


